package com.label.Thread;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;

public class DataSourceFileWriter {

    private FileWriter dataWriter;
    private BufferedWriter dataBufferedWriter;


    public DataSourceFileWriter(String fileName) throws IOException {
        //File newfile = new File("/home/hadoop/temp/data/"+fileName);
        File newfile = new File("C:\\Users\\75046\\Desktop\\占有\\"+fileName);
        if (!newfile.exists()) {
            newfile.createNewFile();
        }
        this.dataWriter = new FileWriter(newfile, true);
        this.dataBufferedWriter = new BufferedWriter(dataWriter);
    }

    public  synchronized  void  writeData(String str) throws IOException {
        dataBufferedWriter.write(str);
    }

    public void closeFile() throws IOException {
        dataBufferedWriter.close();
        dataWriter.close();
    }
}
